package com.hzw.saas.api.msg.enums;

/**
 * <p>
 * 消息类型
 * </p>
 *
 * @author sonam
 * @since 2021/1/9
 */
public enum MsgCode {

    SUCCESS(1,"通过"),
    FAIL(0,"拒绝"),
    ERROR(-1,"错误");
    /**
     * 状态代号
     */
    private final int code;

    /**
     * 状态文本
     */
    private final String text;

    MsgCode(int code, String text) {
        this.code = code;
        this.text = text;
    }

    public int code() {
        return code;
    }

    public String text() {
        return text;
    }

    public static MsgCode instance(int code) {
        for (MsgCode value : values()) {
            if (value.code() == code) {
                return value;
            }
        }
        return null;
    }
}

